// TorrentES.java
package com.example.demo.model.es;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.*;

import java.time.LocalDate;  // 替换 LocalDateTime
import java.time.LocalDateTime;
import java.util.Date;

@Data
@Document(indexName = "torrents")
public class TorrentES {
    @Id
    private Long id;

    // 为需要模糊搜索的字段添加keyword类型
    @MultiField(
            mainField = @Field(type = FieldType.Text, analyzer = "ik_max_word"),
            otherFields = {
                    @InnerField(suffix = "raw", type = FieldType.Keyword)
            }
    )
    private String fileName;

    @Field(type = FieldType.Long)
    private Long fileSize;

    @Field(type = FieldType.Keyword)
    private String infoHash;

    @Field(type = FieldType.Long)
    private Long uploaderId;

    @Field(type = FieldType.Date, format = DateFormat.date_hour_minute_second)  // 或 pattern = "yyyy-MM-dd'T'HH:mm:ss"
    private LocalDateTime createTime;

    @Field(type = FieldType.Integer)
    private int seeders;

    @Field(type = FieldType.Integer)
    private int leechers;

    @Field(type = FieldType.Integer)
    private Integer status;

    @Field(type = FieldType.Date)
    private LocalDateTime reviewedAt;

    @Field(type = FieldType.Long)
    private Long reviewedBy;

    @Field(type = FieldType.Text, analyzer = "ik_max_word")
    private String summary;

    @Field(type = FieldType.Integer)
    private int score;

    @Field(type = FieldType.Boolean)
    private boolean promotionFree;

    @Field(type = FieldType.Integer)
    private int originalScore;

    @Field(type = FieldType.Date)
    private LocalDateTime promotionStartTime;

    @Field(type = FieldType.Date)
    private LocalDateTime promotionEndTime;

    public Long getId() {
        return id;
    }
}